<?php
class News_model extends CI_Model {

	public function __construct()
	{
		$this->load->database();
	}
	
	public function get_news($slug = FALSE)
{
	if ($slug === FALSE)
	{
		$query = $this->db->query("select * from crud limit 1,10");
		$raro= $this->db->count_all_results('crud');
		//$fields = $this->db->list_fields('crud');
                $fields=  $this->db->list_fields('ctud');
		
	
	$data = array('total'=>''.$raro.'','rows' => $query->result_array());
		return $data;
	}
	//**********
	
	
}

public function set_news()
{
//	$this->load->helper('url');
        $this->load->helper('url');
        
	$slug = url_title($this->input->post('title'), 'dash', TRUE);
	

	
	$data = array(
		
		'nombre' => $this->input->post('nombre'),
		'descripcion' => $this->input->post('descripcion'),
		'url' => $this->input->post('url')

	);
	
	
	//return $this->db->insert('crud', $data);
        return $this->db->insert('crud', $data);
        
	
}
/*
public function delete_news()
{
	$id = intval($_REQUEST['id']);
	$this->load->helper('url');
	$slug = url_title($this->input->post('title'), 'dash', TRUE);
	
	
	
	
	return $this->db->delete('news', $id);
}

*/

public function update_new($id, $nombre, $descripcion, $url) {
			$data = array(
				'nombre' => $nombre,
				'descripcion' => $descripcion,
				'url' => $url
				
			);
			$this->db->where('id', $id);
			return $this->db->update('crud', $data);
		}
	
	

}